#pragma once

#include <string>
#include <unordered_map>

namespace MiniDB
{

    // 词法单元类型枚举
    enum class TokenType
    {
        // 关键字
        SELECT,
        FROM,
        WHERE,
        INSERT,
        INTO,
        VALUES,
        UPDATE,
        SET,
        DELETE,
        CREATE,
        TABLE,
        DROP,
        ALTER,
        ADD,
        COLUMN,
        DATABASE,
        USE,
        SHOW,
        TABLES,
        DESCRIBE,
        BEGIN,
        COMMIT,
        ROLLBACK,
        TRANSACTION,
        PRIMARY,
        KEY,
        NOT,
        NULL_TOKEN,

        // 数据类型
        INT,
        VARCHAR,
        FLOAT,
        BOOLEAN,
        DATE,
        TEXT,

        // 操作符
        EQUALS,
        NOT_EQUALS,
        GREATER,
        LESS,
        GREATER_EQUALS,
        LESS_EQUALS,
        AND,
        OR,
        LIKE,
        IN,
        BETWEEN,
        IS,

        // 分隔符
        COMMA,
        SEMICOLON,
        LPAREN,
        RPAREN,
        DOT,
        STAR,

        // 字面量
        IDENTIFIER,
        STRING_LITERAL,
        NUMBER_LITERAL,

        // 特殊标记
        EOF_TOKEN
    };

    // 词法单元类
    class Token
    {
    public:
        TokenType type;
        std::string value;
        int line;
        int column;

        Token(TokenType t, const std::string &v, int l, int c)
            : type(t), value(v), line(l), column(c) {}

        std::string toString() const;
    };

    // TokenType到字符串的映射
    extern std::unordered_map<TokenType, std::string> tokenTypeNames;

} // namespace MiniDB
